from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModPendingProDet import PendingProDet, pendingProDetSchema
from database import Session, engine
import datetime


def get_problem_list(session, bureauid: str, stationid: str):
    # 局方待处理问题明细
    if stationid == "00":
        problem_list = session.query(PendingProDet).filter(PendingProDet.bureauid == bureauid).order_by(
            PendingProDet.initial_time.asc()).all()
    else:
        problem_list = session.query(PendingProDet).filter(PendingProDet.bureauid == bureauid).filter(
            PendingProDet.stationid == stationid).order_by(PendingProDet.initial_time.asc()).all()
    return JSONResponse(pendingProDetSchema.dump(problem_list, many=True).data)
